"""MeiDuo URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/3.1/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.urls import path, include, register_converter

from apps.users.views import UsernameCountView, RegisterView, LoginView, LogoutView, UserInfoView, SaveEmailView, \
    EmailVerifyView, AddressCreateView, AddressView, UpdateDestroyAddressView, DefaultAddressView, \
    UpdateTitleAddressView, ChangePasswordView

# 注册用户名验证的转换器 别名uname
from utils.converters import UsernameConverter

register_converter(UsernameConverter, 'uname')

urlpatterns = [
    path('usernames/<uname:username>/count/', UsernameCountView.as_view()),  # 检查用户名
    path('register/', RegisterView.as_view()),  # 注册
    path('login/', LoginView.as_view()),  # 登录
    path('logout/', LogoutView.as_view()),  # 退出
    path('info/', UserInfoView.as_view()),  # 用户中心
    path('emails/', SaveEmailView.as_view()),  # 用户中心
    path('emails/verification/', EmailVerifyView.as_view()),  # 用户中心

    path('addresses/create/', AddressCreateView.as_view()),  # 添加收货地址
    path('addresses/', AddressView.as_view()),  # 展示收货地址
    path('addresses/<address_id>/', UpdateDestroyAddressView.as_view()),  # 修改/删除收货地址
    path('addresses/<address_id>/default/', DefaultAddressView.as_view()),  # 设置默认地址
    path('addresses/<address_id>/title/', UpdateTitleAddressView.as_view()),  # 修改地址标题

    path('password/', ChangePasswordView.as_view()),  # 修改密码
]
